package com.traval.util;

import java.sql.Timestamp;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.traval.goods.models.TGoods;
import com.traval.goods.models.TPlaneticket;
import com.traval.goods.models.TRoom;
import com.traval.goods.models.TTravalticket;

public class test_01 {

	public static void main(String[] args) {
		TGoods g = new TGoods();
		TTravalticket t = new TTravalticket();
		TRoom r = new TRoom();
		TPlaneticket p = new TPlaneticket();
		
		p.setAriveTime(new Timestamp(11));
		p.setDeparture(new Timestamp(11));
		p.setDestination("上海");
		p.setFlightNumber("ad");
		p.setPlaneName("as");
		p.setPrice(120.4);
		p.setSeatNumber("12");
		p.setStartPlace("北京");
		
		r.setBedNumbers(4);
		r.setCheckinTime(new Timestamp(11));
		r.setCheckoutTime(new Timestamp(12));
		r.setHotelName("万家乐大酒店");
		r.setPrice(200.2);
		r.setRoomNumber("ad");
		r.setRoomType("豪华");

		t.setPrice(100.0);
		t.setScenicSpotAddress("北理工");
		t.setScenicSpotCloseTime(new Timestamp(11));
		t.setScenicSpotName("圆明新园");
		t.setScenicSpotOpenTime(new Timestamp(10));

		g.setCount(30);
		g.setName("组合一号");
		g.setPrice(50.0);
		g.getTRooms().add(r);
		g.getTTravaltickets().add(t);
		g.getTPlanetickets().add(p);
		
		Session session = HibernateSessionFactory.getSession();
		Transaction tx = session.beginTransaction();
		session.save(g);
		tx.commit();
		HibernateSessionFactory.closeSession();
	}

}
